package Offer;

public class Test40 
{

	public static void main(String[] args) 
	{
		int[] array={1,2,2,3,3,4,5,6,6,5};
		findNumsAppearOnce(array);

	}
	public static void findNumsAppearOnce(int[] array)
	{
		if(array==null||array.length<2)
			return;
		int result=0;
		for(int i=0;i<array.length;i++)
		{
			result^=array[i];
		}
		int index=find1(result);
		int num1=0;
		int num2=0;
		for(int i=0;i<array.length;i++)
		{
			if(isBit1(array[i],index))
			{
				num1^=array[i];
			}
			else
			{
				num2^=array[i];
			}
		}
		System.out.println(num1+" "+num2);
	}
	public static int find1(int result)
	{
		int index=0;
		while((result&1)==0)
		{
			result=result>>1;
		    ++index;
		}
		return index;
	}
	public static boolean isBit1(int num,int index)
	{
		num=num>>index;
		if((num&1)!=0)
		{
			return true;
		}
		return false;
		
	}
}
